package com.hxd.otc.module.convenience.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.convenience.bean.RefuelingServiceBean;
import com.hxd.otc.module.convenience.contract.OilListContract;
import com.hxd.otc.module.convenience.model.ConvenienceModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

import java.util.ArrayList;
import java.util.List;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/6/4 17:02
 * 描  述 :  ${所有订单页面}
 */
public class OilListPresenter extends BasePresenter<OilListContract.View> implements OilListContract.Presenter {

    ConvenienceModel model;
    private String parentId;

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public OilListPresenter(OilListContract.View view) {
        super(view);
        model = ConvenienceModel.getInstance();
    }

    @Override
    public void start() {

        model.getModuleList(parentId, new BaseObserver<ArrayList<RefuelingServiceBean>>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull ArrayList<RefuelingServiceBean> beans) {
                doSetAdapter(beans);
                doShowNoMore();
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                doShowNoMore();
            }
        }, mView.<BaseBean<ArrayList<RefuelingServiceBean>>>bindAutoDispose());

    }


    @Override
    public void doShowNoMore() {
        mView.onShowNoMore();
    }

    @Override
    public void doSetAdapter(List<RefuelingServiceBean> list) {

        mView.onSetAdapter(list);
    }

}
